package com.bqtv.sport.commen.dialog

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.widget.FrameLayout
import androidx.annotation.StringRes
import com.hjq.base.BaseDialog
import com.hjq.base.action.AnimAction
import com.bqtv.sport.databinding.WaitDialogBinding

/**
 *    desc   : 等待加载对话框
 */
class WaitDialog {

    class Builder(context: Context) : BaseDialog.Builder<Builder>(context) {
        var binding: WaitDialogBinding =
            WaitDialogBinding.inflate(LayoutInflater.from(context), FrameLayout(context), false)

        init {
            setContentView(binding.root)
            setAnimStyle(AnimAction.ANIM_TOAST)
            setBackgroundDimEnabled(false)
            setCancelable(false)
        }

        fun setMessage(@StringRes id: Int): Builder = apply {
            setMessage(getString(id))
        }

        fun setMessage(text: CharSequence?): Builder = apply {
            binding.tvWaitMessage.text = text
            binding.tvWaitMessage.visibility = if (text == null) View.GONE else View.VISIBLE
        }
    }
}